/*
 * ClaplanHeader.h
 *
 *  Created on: 30 Oct 2013
 *      Author: Tom Vercauteren
 */

#ifndef CLAPLANHEADER_H_
#define CLAPLANHEADER_H_

#include <string>
#include <ostream>
#include "claplan_print.h"

using std::string;
using std::endl;

struct ClaplanHeaderMask
{
	/** file version (1 if set, 0 if not)*/
	unsigned char version :1;
	/** mode (1 if set, 0 if not)*/
	unsigned char mode :1;
	/** unused but set for memory alignement (padding) */
	unsigned char :6;
};

/**
 * Contains the data of the header in a claplan.
 */
class ClaplanHeader
{
private:
	/** Mask to determine which parameters have been set and which haven't.*/
	ClaplanHeaderMask mask;
	/** file version */
	int version;
	/** mode */
	int mode;
public:

	ClaplanHeader() :
			version(0), mode(0)
	{
		mask.mode = 0;
		mask.version = 0;
	}

	ClaplanHeader(const ClaplanHeader &header);
	ClaplanHeader& operator=(const ClaplanHeader &header);
	/**
	 * Get claplan header mode.
	 * @return Header mode
	 */
	int getMode() const;
	/**
	 * Set claplan header mode and set the corresponding mask to 1.
	 * @param mode Header mode
	 */
	void setMode(int mode);
	/**
	 * Unset claplan header mode and set the corresponding mask to 0.
	 */
	void unsetMode();
	/**
	 * Check if the claplan header mode parameter was set.
	 * @return
	 * <ul>
	 * 	<li>1 : mode was set</li>
	 * 	<li>0 : mode was not set</li>
	 * </ul>
	 */
	unsigned char isModeSet() const;
	/**
	 * Get claplan header version.
	 * @return Header version
	 */
	int getVersion() const;
	/**
	 * Set claplan header version and set the corresponding mask to 1.
	 * @param version Header version
	 */
	void setVersion(int version);
	/**
	 * Unset claplan header version and set the corresponding mask to 0.
	 */
	void unsetVersion();
	/**
	 * Check if the claplan header version parameter was set.
	 * @return
	 * <ul>
	 * 	<li>1 : version was set</li>
	 * 	<li>0 : version was not set</li>
	 * </ul>
	 */
	unsigned char isVersionSet() const;

	friend std::ostream & operator<<(std::ostream & os,
			const ClaplanHeader &header);
};

#endif /* CLAPLANHEADER_H_ */
